var findString = function(words, s) {
    var left = 0, right = words.length-1, middle = 0, temp = -1;
    while(left<=right){
        middle = Math.floor((left+right)/2);
        temp = middle; // backup
        while(middle>=left && words[middle]===''){
            middle--;
        }
        if(middle<left){
            left = temp+1;
            continue;
        }
        if(words[middle]>s){
            right = middle-1;
        } else if(words[middle]<s){
            left = middle+1;
        } else{
            return middle;
        }
    }
    return -1;
};

var arr = [], length = 100, left = 0, right = length - 1, middle = 0, target = 10, count = 0;
for(let i=0;i<length;i++) arr.push(i);
while(left<right){
    middle = Math.floor((left+right)/2);
    count++;
    if(arr[middle]<target){
        left = middle;
    } else if(arr[middle]>target){
        right = middle;
    } else{
        break;
    }
}
// console.log(middle, count);
var words = ["at", "", "", "", "ball", "", "", "car", "", "","dad", "", ""], s = "ball";
        //    0    1    2   3     4     5   6    7     8   9   10   11  12 
// console.log(findString(words,s));
console.log('a'.codePointAt(0), 'A'.codePointAt(0));
